<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>打卡记录</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style type="text/css">
        .aui-list .wechat-avatar {
            width:3rem;
        }
        .wechat-avatar .aui-row-padded {
            background-color: #dddee0;
            padding: 0.1rem;
            border-radius: 0.2rem;
            margin-left: -0.05rem;
            margin-right: -0.05rem;
        }
        .wechat-avatar .aui-row-padded [class*=aui-col-xs-] {
            padding: 0.05rem;
        }
        .wechat-avatar,
        .wechat-avatar > img {
            border-radius:0.2rem;
        }
        /* .place {
            text-overflow: ellipsis !important;
            white-space:nowrap;
            overflow: hidden;
            width: 13rem;
        } */
    </style>
</head>
<body>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="signListUl">
            <!-- <li class="aui-list-item aui-list-item-middle">
                <div class="aui-media-list-item-inner">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-text">
                            <div class="aui-list-item-title">欢迎使用在线文档</div>
                        </div>
                        <div class="aui-list-item-text aui-font-size-12">
                            <span class="username">admin</span> 
                            <span class="createtime">2017-07-20 11:22:33</span>
                        </div>
                    </div>
                </div>
            </li> -->
        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../script/aui-toast.js" ></script>
<script type="text/javascript">
var toast = new auiToast();
apiready = function(){
    // 加载数据
    $api.setStorage("sign_index", 0);
    load();
    //上拉翻页
    api.addEventListener({
        name : 'scrolltobottom'
    }, function(ret, err) {
        $api.setStorage("sign_index", $api.getStorage("sign_index") - 0 + 1);
        load();
    });
    // 加载内容列表
    function load () {
        // alert($api.getStorage("sign_index"))
        api.showProgress({
           style: 'default',
           animationType: 'fade',
           title: '拼命加载中...',
           text: '不如喝茶去...',
           modal: false
        });
        api.ajax({
            url: ServeUrl + 'm=Sign&a=getSign',
            method: 'post',
            dataType : 'json',
            data: {
                values: {
                    index: $api.getStorage("sign_index"),
                    username: $api.getStorage("username"),
                },
            },
        }, function(ret, err) {
            // alert(err);
            if (ret) {
                var str = '';
                for (var i = 0; i <ret.length; i++) {
                    str += '<li class="aui-list-item aui-list-item-middle" onclick="openWin('+ret[i].id+')">';
                    str += '<div class="aui-media-list-item-inner">';
                    str += '    <div class="aui-list-item-media wechat-avatar">';
                    if ($api.getStorage("user_img")) {
                        str += '        <img src="'+ServeIp+'/include/data/headImg/'+$api.getStorage("user_img")+'" />';
                    } else {
                        str += '        <img src="../image/emptyHead.jpg" />';
                    }
                    str += '    </div>';
                    str += '    <div class="aui-list-item-inner">';
                    str += '        <div class="aui-list-item-text">';
                    str += '            <div class="aui-list-item-title">'+ret[i].username+'</div>';
                    str += '            <div class="aui-list-item-right">'+ret[i].formattime+'</div>';
                    str += '        </div>';
                    str += '        <div class="aui-list-item-text aui-font-size-12 place">'+ret[i].place+'</div>';
                    str += '    </div>';
                    str += '</div>';
                    str += '</li>';
                }
                $('#signListUl').append(str);
                api.hideProgress();
            } else {
                toast.success({
                    title:"已加载所有签到记录",
                    duration:2000
                });
                api.hideProgress();
            }
        });
    }
};

function openWin(id) {
    api.openWin({
        name: 'sign_details',
        url: 'sign_details_win.html',
        pageParam: {
            id : id
        }
    });
}

// alert( $api.getStorage("user_img"))

</script>
</html>